package cn.batch.daemon;

import java.text.ParseException;
import java.util.Calendar;
import java.util.Date;

import cn.batch.daemon.loadBatch.RiskWarnMonthSendInfoFromRiskData;
import cn.batch.daemon.util.ConstantParameter;
import cn.batch.daemon.util.DateUtil;

/**
 * 风险预警-按月处理(客户人行征信检核及发送入口程序)
 * 
 * @author xihn
 * 
 */
public class RiskWarningSendFromRiskData {

	public static void main(String[] args) throws Exception {
		int argsLength = args.length;
		if (argsLength < 1) {
			throw new IllegalArgumentException("请传入需要加载的数据日期字符串。格式: yyyyMMdd");
		}

		String s = args[0];
		Date bDate = null;
		try {
			bDate = DateUtil.fromString(s, "yyyyMMdd");
		} catch (ParseException e) {
			throw new IllegalArgumentException("参数格式无效。格式：yyyyMMdd");
		}
		
		Configuration config = new Configuration();
		int runDay = config.getSetting(ConstantParameter.RISKWARN_RUN_DAY, 0);
		if (argsLength == 1) {
			Calendar calendar = Calendar.getInstance();
			calendar.setTime(bDate);
			if (calendar.get(Calendar.DAY_OF_MONTH) != runDay - 1) {
				System.out.println("非指定运行日期。");
				System.exit(0);
			}
		}

		RiskWarnMonthSendInfoFromRiskData riskWarnMonthSendInfoFromRiskData = new RiskWarnMonthSendInfoFromRiskData(config);
		riskWarnMonthSendInfoFromRiskData.setBatchDate(s);
		riskWarnMonthSendInfoFromRiskData.run();
		System.exit(0);
	}
}
